package org.codeart.observer.house1;

import org.codeart.observer.dto.LotteryResult;

import java.util.Date;

public class LotteryServiceImpl implements LotteryService {
    
    // 注入摇号服务
    private final DrawHouseService drawHouseService = new DrawHouseService();

    @Override
    public LotteryResult lottery(String uid) {
        // 摇号
        String result = drawHouseService.lots(uid);
        
        // 发短信
        System.out.printf("发送短信通知用户，ID 为: %s，您的摇号结果为: %s\n", uid, result);
        
        // 发送消息给MQ
        System.out.printf("记录用户摇号结果到 MQ，ID 为: %s，摇号结果为: %s\n", uid, result);
        
        return new LotteryResult(uid, result, new Date());
    }
}
